package edu.umassd.visual.options;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.springframework.stereotype.Component;

import processing.core.PFont;
import say.swing.JFontChooser;

/**
 * This action gets a font to use when drawing things.
 * 
 * @author Dan Avila
 * 
 */
@Component("font")
public class SelectFont implements ActionListener
{
	private volatile PFont font = new PFont(Font.decode("Arial"), true);
	private volatile PFont bigFont = new PFont(Font.decode("Arial-18"), true);

	@Override
	public void actionPerformed(ActionEvent e)
	{
		JFontChooser fontChooser = new JFontChooser();
		int result = fontChooser.showDialog(null);

		if (result == JFontChooser.OK_OPTION)
		{
			font = new PFont(fontChooser.getSelectedFont(), true);
			String fontType = font.getName() + "-"
					+ (int) (font.getSize() * 1.5);
			bigFont = new PFont(Font.decode(fontType), true);
		}

	}

	public PFont getFont()
	{
		return font;
	}

	public PFont getBigFont()
	{
		return bigFont;
	}
}
